<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>class和style绑定</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>

<body>
    <script>
    </script>

</body>
<!-- 绑定到HTML class -->
<div id="app1">

    <!-- 对象语法1 -->
    <div v-bind:class="{ active: isActive, 'text-danger': hasError }">绑定到对象1 </div>
    <!-- 对象语法2 -->
    <div :class="classObject"></div>
    <!-- 数组语法  -->
    <div :class="[activeClass, errorClass]"></div>
</div>
<script>
    new Vue({
        el: "#app1",
        data: {
            isActive: true,
            hasError: false,
            activeClass: "active",
            errorClass: "text-danger",
            classObject: {
                active: true,
                'text-danger': false
            }
        },
        method: {

        }
    });
</script>
<!-- 绑定到内联样式 -->
<div id="app2">
    <div :style="{ color: activeColor, fontSize: fontSize + 'px' }">绑定到样式 对象语法1</div>
    <div v-bind:style="styleObject">绑定到样式 对象语法2</div>
    <div v-bind:style="[baseStyles, overridingStyles]">数组语法</div>
    密码：<input type="text" placeholder="请输入密码">
</div>
<script>
    new Vue({
        el: "#app2",
        data: {
            activeColor: 'red',
            fontSize: 30,
            styleObject: {
                color: 'red',
                fontSize: "30px"
            },
            baseStyles: {
                color: "blue",
                fontSize: "20px"
            },
            overridingStyles: {
                background: "green",

            }
        },
        method: {}

    });
</script>
<div id="example-4">
    <input type="radio" id="one" value="One" v-model="picked">
    <label for="one">Onet</label>
    <br>
    <input type="radio" id="two" value="Two" v-model="picked">
    <label for="two">Twot</label>
    <br>
    <span>Picked: {{ picked }}</span>
</div>

<script>
    new Vue({
        el: "#example-4",
        data: {
            picked: ""
        }
    });
</script>

</html>